package com.srit.map.web.action;

import java.io.PrintWriter;

import org.apache.struts2.json.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;

import com.srit.core.struts2.action.CrudAction;
import com.srit.map.business.bean.Report;
import com.srit.map.business.service.ReportService;

public class ReportAction extends CrudAction{
	
	Report report = new Report();
	@Autowired(required = true)
	private ReportService reportService;
	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return report;
	}
	
	public void insert(){
		String name = request.getParameter("name");
		String value = request.getParameter("value");
		report.setName(name);
		report.setValue(value);
		reportService.insert(report);
	}
	
	public void pageCount(){
		int num = reportService.pageCount(page);
		response.setContentType("application/json;charset=UTF-8");
		PrintWriter out;
		try {
			out = response.getWriter();
			out.println(num);
			out.flush();
			out.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
